<?php
/**
 * Created by PhpStorm.
 * User: cx
 * Date: 2019-01-08
 * Time: 18:44
 */

namespace services\api;

class ApiBearerAuth extends BaseHeaderAuth
{
    /**
     * {@inheritdoc}
     */
    public $header = 'Authorization';

    /**
     * {@inheritdoc}
     */
    public $pattern = '/^Bearer\s+(.*?)$/';

    /**
     * @var string the HTTP authentication realm
     */

    public $realm = 'api';

    /**
     * {@inheritdoc}
     */
    public function challenge($response)
    {
        $response->getHeaders()->set('WWW-Authenticate', "Bearer realm=\"{$this->realm}\"");
    }

}